//
//  FWTitleView.m
//  BirdLoveSheep
//
//  Created by wwj on 16/3/11.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWTitleView.h"

@interface FWTitleView ()
@property (weak, nonatomic) IBOutlet UIView *buttomView;
@property (weak, nonatomic) IBOutlet FWTitleButton *btnA;
@property (weak, nonatomic) IBOutlet FWTitleButton *btnB;
@property (weak, nonatomic) FWTitleButton *selectBtn;
@end

@implementation FWTitleView

- (void)awakeFromNib{
    self.buttomView.center = _btnA.center;
    self.buttomView.width = _btnA.width - 4;
    _selectBtn = self.btnA;
    
}

+ (instancetype)titleView{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}

- (void)setFrame:(CGRect)frame{
    frame.size = CGSizeMake(130, 44);
    [super setFrame:frame];
}

- (IBAction)onClickBtn:(FWTitleButton *)sender {
    
    if ([_delegate respondsToSelector:@selector(onClickTitleViewFrom:to:)]) {
        [_delegate onClickTitleViewFrom:_selectBtn.tag to:sender.tag];
    }
    
    [UIView animateWithDuration:0.3 animations:^{
        self.buttomView.center = CGPointMake(sender.center.x, self.height - 1);
    }];
    _selectBtn = sender;
}

- (void)layoutSubviews{
    [super layoutSubviews];
     self.buttomView.center = CGPointMake(_selectBtn.center.x, self.height - 1);
}


@end

@implementation FWTitleButton

- (void)setHighlighted:(BOOL)highlighted{}

@end